﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ccit.Utils;
using Ccit.ClassLibrary;

namespace Ccit.SysPlat.Organ
{
    /// <summary>
    /// Description: 系统平台组织机构 -> 级别管理业务层
    /// Author: tim 2010-02-23
    /// </summary>
    public class ClsBLL
    {
        #region initialize 

        IClass _clsProcessor = null;

        public ClsBLL()
        {
            _clsProcessor = Factory.CreateObject(MsClass.assemblyName, MsClass.className, ImportComponentType.DotNetDll, null) as IClass;
        }

        public void Release()
        {
            _clsProcessor = null;
        }
        #endregion

        /// <summary>
        /// 获取机构下的级别记录名-值对儿字典集合
        /// </summary>
        /// <param name="organId">机构Id</param>
        /// <param name="filterClsIds">过滤掉的级别记录Id串</param>        
        /// <returns></returns>
        public List<MsKeyValue> GetClsListByOrgan(string organId, string filterClsIds)
        {
            if (string.IsNullOrEmpty(organId)) return new List<MsKeyValue>();
            return _clsProcessor.GetClsListByOrgan(organId, filterClsIds,string.Empty);
        }

        /// <summary>
        /// 获取级别消息对象
        /// </summary>
        /// <param name="clsId">级别Id</param>
        /// <returns></returns>
        public MsClass GetClsInfo(string clsId)
        {
            if (string.IsNullOrEmpty(clsId)) return null;

            MsClass msCls = _clsProcessor.GetClsInfo(clsId);
            return msCls;
        }

        /// <summary>
        /// 保存级别信息
        /// </summary>
        /// <param name="msCls">级别信息消息对象</param>
        /// <returns>
        ///     【0】: 操作结果
        ///     【1】: 操作提示
        /// </returns>
        public List<string> Save(MsClass msCls)
        {
            if (null == msCls) return new List<string> { "-999", "操作失败:缺少必要参数!" };
            List<string> lstResult = _clsProcessor.Save(msCls);
            return lstResult;
        }

        /// <summary>
        /// 级别名称同名校验
        /// </summary>
        /// <param name="clsName">级别名称</param>
        /// <param name="clsId">级别Id</param>
        /// <returns></returns>
        public List<string> IsExistClsName(string clsName, string clsId, string organId)
        {
            if (string.IsNullOrEmpty(clsName)) return new List<string> { "ERROR", "校验失败:缺少必要参数!" };

            List<string> lstResult = _clsProcessor.IsExistClsName(clsId, clsName, organId);
            return lstResult;
        }

        /// <summary>
        /// 删除级别记录
        /// </summary>
        /// <param name="clsId">级别Id</param>
        /// <returns>
        ///     【0】: 操作结果
        ///     【1】: 操作提示
        /// </returns>
        public List<string> Delete(string clsId)
        {
            if (string.IsNullOrEmpty(clsId)) return new List<string> { "-999", "操作失败:缺少必要参数!" };
            List<string> lstResult = _clsProcessor.Delete(clsId);
            return lstResult;
        }
    }
}
